let uid = 0
export class Dep {
  constructor() {
    this.id = ++uid
    console.log('创建Dep');
    // 放的是watcher的实例
    this.subs = new Set()
  }
  // 添加当前激活的Watcher为依赖
  depend() {
    // 全局唯一的target
    if (Dep.target) {
      this.subs.add(Dep.target)
    }
  }
  // 通知更新
  notify() {
    console.log('====== dep 通知 watcher 更新');
    const subs =[...this.subs]
    for(let i = 0, l = subs.length; i < l; i++) {
      subs[i].update()
    }
  }
}